

// declare that we need a OBJModel and we'll be calling it "model"

float rotX;
float rotY;
float posX=0;
float posY=0;
// these booleans will be used to turn on and off bits of the OBJModel
boolean bTexture = true;
boolean bStroke = false;
boolean bMaterial = false;
Animation anim;
void setup()
{
  anim = new Animation(this, "s");
  frameRate(60);
  size(600, 600, P3D);
  text("test", 100, 100);

  noStroke();
}
int i = 0;
void draw()
{
  //saveFrame("D_ " +i+".png");
  background(32, 20);
  lights();
  //this will do nothing until the model material is turned off
  fill(255);

  pushMatrix();
  translate(width/2, height/2, 0);
  translate(posX, posY, 0);
  rotateY(rotX);
  rotateX(rotY);
  println(rotX + " " +  rotY);
  noStroke();
  bStroke = false;
  //model[i].draw();
  anim.Draw();
  popMatrix();
}



void keyPressed() {
  println(posX + " " + posY);
  // turns on and off the texture listed in .mtl file
  if (key=='w')
  {
    posY+=10;
  }
  else
  {
    if (key=='s')
    {
      posY-=10;
    }
  }
  if (key == 't') {
    if (!bTexture) {
      for (int x = 0; x <=48;x++)
      {
        anim.getFrame().enableTexture();
      }
      bTexture = true;
    } 
    else {
      for (int x = 0; x <=48;x++)
      {
        anim.getFrame().disableTexture();
      }
      bTexture = false;
    }
  }

  else if (key == 'm') {
    // turns on and off the material listed in .mtl file
    if (!bMaterial) {
      for (int x = 0; x <=48;x++)
      {
        anim.getFrame().enableMaterial();
      }
      bMaterial = true;
    } 
    else {
      for (int x = 0; x <=48;x++)
      {
        anim.getFrame().disableMaterial();
      }
      bMaterial = false;
    }
  }

  /*    else if(key == 's') {
   if(!bStroke) {
   stroke(10, 10, 10);
   bStroke = true;
   } 
   else {
   noStroke();
   bStroke = false;
   }
   }*/

  // the follwing changes the render modes
  // POINTS mode is a little flakey in OPENGL (known processing bug)
  // the best one to use is the one you exported the obj as
  // when in doubt try TRIANGLES or POLYGON

  else if (key=='1') {
    stroke(10, 10, 10);
    //  bStroke = true;
    for (int x = 0; x <=48;x++)
    {
      anim.getFrame().shapeMode(POINTS);
    }
  }

  else if (key=='2') {
    stroke(10, 10, 10);
    // bStroke = true;
    for (int x = 0; x <=48;x++)
    {
      anim.getFrame().shapeMode(LINES);
    }
  }

  else if (key=='3') 
  {
    for (int x = 0; x <=48;x++)
    {
      anim.getFrame().shapeMode(TRIANGLES);
    }
    bStroke =false;
  }

  else if (key=='4') 
  {
    for (int x = 0; x <=48;x++)
    {

      anim.getFrame().shapeMode(POLYGON);
    }
  }

  else if (key=='5') {
    for (int x = 0; x <=48;x++)
    {
      anim.getFrame().shapeMode(TRIANGLE_STRIP);
    }
  }

  else if (key=='6') {
    for (int x = 0; x <=48;x++)
    {
      anim.getFrame().shapeMode(QUADS);
    }
  }

  else if (key=='7') {
    for (int x = 0; x <=48;x++)
    {
      anim.getFrame().shapeMode(QUAD_STRIP);
    }
  }
}

void mouseDragged()
{
  rotX += (mouseX - pmouseX) * 0.01;
  rotY -= (mouseY - pmouseY) * 0.01;
}

